home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 001a / tm301_2.zip / TOOLBOX1.SCR < prev    next >
Text File  |  1992-01-03  |  10KB  |  331 lines

  1. ;
  2. ; TOOLBOX1.SCR (c) Copyright 1990-1992 by White River Software.
  3. ; All right reserved.
  4. ;
  5. ; Date written: 10 May 1990
  6. ;
  7. ;
  8. ; This toolbox defines video color, ANSI color code and a set of
  9. ; video procedures which output to local screen and/or remote
  10. ; system.
  11. ;
  12. ; To use this toolbox, you should add the line
  13. ;    #include "toolbox1.scr"
  14. ; at the beginning of your script file.  This will increase the file
  15. ; size of the compiled script file .TMS by about 4K.  To minimum the
  16. ; overhead, you should cut and paste the procedures that you used into
  17. ; your script file.  For example, the <EchoBox> and <EchoBlock>
  18. ; procedures may be excluded.
  19. ;
  20. ; The <EchoToLocol> and <EchoToRemote> variables tell the Echo
  21. ; procedures where the output is to be sent.  If <EchoToLocal>
  22. ; is TRUE, the output is sent to the local screen.  If <EchoToRemote>
  23. ; is TRUE, the output is sent to the remote system.  These variable
  24. ; can both be TRUE.
  25. ;
  26. ; The BLACK, BLUE, GREEN, CYAN, RED, YELLOW and WHITE contains the
  27. ; color value used by IBM PC.  This order is not the same as that
  28. ; of ANSI.  The ANSI color codes with FG prefix denote the foreground
  29. ; color codes while the BK prefix denote the background ones.
  30. ;
  31. ; Summary:
  32. ;
  33. ;   Echo s            ; output <s> to local screen and/or remote system
  34. ;   EchoInt i         ; output integer <i>
  35. ;   EchoColor color   ; set foreground color
  36. ;   EchoBkColor color ; set background color
  37. ;   EchoNormal        ; normal attribute, white on black
  38. ;   EchoHiLite        ; set high intensity
  39. ;   EchoBlink         ; set blink attribute
  40. ;   EchoReverse       ; set reverse attribute
  41. ;   EchoClearScreen   ; clear screen
  42. ;   EchoGotoXY x,y    ; position cursor to (x,y)
  43. ;   EchoBox   left,top,right,bottom,style,hollow   ; draw a box
  44. ;   EchoBlock left,top,right,bottom,style,fillchar ; draw a block
  45. ;
  46. ;
  47.  
  48. integer EchoToLocal,EchoToRemote
  49.  
  50. integer BLACK,BLUE,GREEN,CYAN,RED,YELLOW,WHITE
  51. string  FGBLACK,FGBLUE,FGGREEN,FGCYAN,FGRED,FGYELLOW,FGWHITE
  52. string  BKBLACK,BKBLUE,BKGREEN,BKCYAN,BKRED,BKYELLOW,BKWHITE
  53.  
  54. EchoToLocal = 1               ; TRUE to print string to local screen
  55. EchoToRemote = 1              ; TRUE to send string to remote system
  56.  
  57. BLACK   = 0                   ; define color number in IBM PC order
  58. BLUE    = 1
  59. GREEN   = 2
  60. RED     = 3
  61. CYAN    = 4
  62. MAGENTA = 5
  63. YELLOW  = 6
  64. WHITE   = 7
  65.  
  66. FGBLACK   = "^[[30m"          ; define foreground color code in ANSI order
  67. FGRED     = "^[[31m"
  68. FGGREEN   = "^[[32m"
  69. FGYELLOW  = "^[[33m"
  70. FGBLUE    = "^[[34m"
  71. FGMAGENTA = "^[[35m"
  72. FGCYAN    = "^[[36m"
  73. FGWHITE   = "^[[37m"
  74.  
  75. BKBLACK   = "^[[40m"          ; define background color code in ANSI order
  76. BKRED     = "^[[41m"
  77. BKGREEN   = "^[[42m"
  78. BKYELLOW  = "^[[43m"
  79. BKBLUE    = "^[[44m"
  80. BKMAGENTA = "^[[45m"
  81. BKCYAN    = "^[[46m"
  82. BKWHITE   = "^[[47m"
  83.  
  84.  
  85. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  86. ;
  87. ; Echo s
  88. ; function:  print the string <s> to local screen if <EchoToLocal> is TRUE
  89. ;            and send <s> to remote system if <EchoToRemote> is TRUE
  90. ;
  91. Procedure Echo string s
  92. if EchoToLocal
  93.    print s,                   ; print to local screen
  94. endif
  95. if EchoToRemote
  96.    put s,                     ; put to remote system
  97. endif
  98. EndProc
  99.  
  100.  
  101. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  102. ;
  103. ; EchoInt i
  104. ; funcdtion: print the integer <i> to local screen if <EchoToLocal> is TRUE
  105. ;            and send <i> to remote system if <EchoToRemote> is TRUE
  106. ;
  107. Procedure EchoInt integer i
  108. if EchoToLocal
  109.    print i,                   ; print to local screen
  110. endif
  111. if EchoToRemote
  112.    put i,                     ; put to remote system
  113. endif
  114. EndProc
  115.  
  116.  
  117. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  118. ;
  119. ; EchoColor color
  120. ; function: set foreground color
  121. ;
  122. Procedure EchoColor integer color
  123. string code
  124. Switch color
  125.    case 0: code = FGBLACK     ; ANSI code <esc>[3<x>m
  126.    case 1: code = FGBLUE
  127.    case 2: code = FGGREEN     ; Note: IBM PC attribute is not
  128.    case 3: code = FGRED       ;  in the same order of the ANSI
  129.    case 4: code = FGCYAN      ;  color code.
  130.    case 5: code = FGMAGENTA
  131.    case 6: code = FGYELLOW
  132.    otherwise:
  133.            code = FGWHITE
  134. EndSwitch
  135. Echo code
  136. EndProc
  137.  
  138.  
  139. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  140. ;
  141. ; EchoBkColor bkcolor
  142. ; function: set background color
  143. ;
  144. Procedure EchoBkColor integer bkcolor
  145. string code
  146. Switch bkcolor
  147.    case 1: code = BKBLUE      ; ANSI code <esc>[4<x>m
  148.    case 2: code = BKGREEN
  149.    case 3: code = BKRED
  150.    case 4: code = BKCYAN
  151.    case 5: code = BKMAGENTA
  152.    case 6: code = BKYELLOW
  153.    case 7: code = BKWHITE
  154.    otherwise:
  155.            code = BKBLACK
  156. EndSwitch
  157. Echo code
  158. EndProc
  159.  
  160.  
  161. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  162. ;
  163. ; EchoNormal
  164. ; function: set normal intensity and reset color to white on black
  165. ; remark:   to turn off high intensity only, you must use three
  166. ;           statements, where <foreground> and <background> are
  167. ;           foreground and background colors, because there is
  168. ;           no ANSI code to turn off high intensity.
  169. ;       EchoNomal
  170. ;       EchoColor   foreground
  171. ;       EchoBkColor background
  172. ;
  173. Procedure EchoNormal
  174. Echo "^[[0m"                  ; ANSI code <esc>[0m
  175. EndProc
  176.  
  177.  
  178. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  179. ;
  180. ; EchoHiLite
  181. ; function: set high intensity
  182. ;
  183. Procedure EchoHiLite
  184. Echo "^[[1m"                  ; ANSI code <esc>[1m
  185. EndProc
  186.  
  187.  
  188. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  189. ;
  190. ; EchoBlink
  191. ; function: set blink attribute
  192. ;
  193. Procedure EchoBlink
  194. Echo "^[[5m"                  ; ANSI code <esc>[5m
  195. EndProc
  196.  
  197.  
  198. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  199. ;
  200. ; EchoReverse
  201. ; function: set reverse attribute
  202. ;
  203. Procedure EchoReverse
  204. Echo "^[[7m"                  ; ANSI code <esc>[7m
  205. EndProc
  206.  
  207.  
  208. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  209. ;
  210. ; EchoClearScreen
  211. ; function: clear screen and home cursor
  212. ;
  213. Procedure EchoClearScreen
  214. Echo "^[[2J"                  ; ANSI code <esc>[2J
  215. EndProc
  216.  
  217.  
  218. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  219. ;
  220. ; EchoGotoXY column,row
  221. ; function: set cursor position
  222. ; remark:   top-left corner is (0,0)
  223. ;
  224. Procedure EchoGotoXY integer column,row
  225. string code,subcode
  226. code = "^[["                  ; ANSI code <esc>[<row+1>;<column+1>H
  227. itoa row+1,subcode
  228. concat code,subcode           ; Note: internal commands are used
  229. concat code,";"               ;  to preventint call the procedures
  230. itoa column+1,subcode         ;  Echo and EchoInt many times.  This
  231. concat code,subcode           ;  will speed up the process.
  232. concat code,"H"
  233. Echo code
  234. EndProc
  235.  
  236.  
  237. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  238. ;
  239. ; EchoBox left,top,right,bottom,style,fillchar,hollow
  240. ; function: draw a box
  241. ; remark:   top-left corner is (0,0)
  242. ;           <style> selects the border
  243. ;               0   spaces
  244. ;               1   single lines
  245. ;               2   double lines
  246. ;               3   single vertical lines, double horizontal lines
  247. ;               4   double vertical lines, single horizontal lines
  248. ;               5   user-define fill character <fillchar>
  249. ;           if <hollow> is TRUE, the inside of the box is cleared
  250. ;
  251. Procedure EchoBox integer left,top,right,bottom,style,string fillchar,integer hollow
  252. string border,ch,line,space
  253. integer row
  254. EchoGotoXY left,top
  255. Switch style                  ; define border
  256.    case 1: border = "┌─┐│└┘"  ; single lines
  257.    case 2: border = "╔═╗║╚╝"  ; double lines
  258.    case 3: border = "╒═╕│╘╛"  ; single vertical lines, double horizontal lines
  259.    case 4: border = "╓─╖║╙╜"  ; double vertical lines, single horizontal lines
  260.    case 5: strset border,fillchar,1,6 ; user-defined fill character
  261.    otherwise:
  262.            border = "      "  ; space
  263. EndSwitch
  264. substr border,1,1,ch          ; top-left corner
  265. Echo ch
  266. substr border,2,1,ch          ; top border
  267. strset line,ch,1,right-left-1
  268. Echo line
  269. substr border,3,1,ch          ; top-right corner
  270. Echo ch
  271. if hollow                     ; clear inside of the box if <hollow> is non-zero
  272.    strset space," ",1,right-left-1
  273. endif
  274. substr border,4,1,ch          ; vertical border
  275. row = top+1
  276. While row<=bottom-1
  277.    EchoGotoXY left,row        ; goto left border
  278.    Echo ch                    ; vertical border
  279.    if hollow
  280.       Echo space              ; fill inside of border
  281.    elseif right<>left+1
  282.       EchoGotoXY right,row    ; goto right border
  283.    endif
  284.    Echo ch                    ; vertical border
  285.    row = row+1
  286. EndWhile
  287. EchoGotoXY left,bottom
  288. substr border,5,1,ch          ; bottom-left corner
  289. Echo ch
  290. Echo line                     ; bottom border
  291. substr border,6,1,ch
  292. Echo ch                       ; bottom-right corner
  293. EndProc
  294.  
  295.  
  296. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  297. ;
  298. ; EchoBlock left,top,right,bottom,style,fillchar
  299. ; function: draw a block of character
  300. ; remark:   top-left corner is (0,0)
  301. ;           <style> selects the type of the block
  302. ;               0   space                  ' '
  303. ;               1   widely spaced block    '░'
  304. ;               2   spaced block           '▒'
  305. ;               3   closely spaced block   '▓'
  306. ;               4   solid block            '█'
  307. ;               5   user-defined fill character <fillchar>
  308. ;
  309. Procedure EchoBlock integer left,top,right,bottom,style,string fillchar
  310. string ch,line
  311. integer row
  312. EchoGotoXY left,top
  313. Switch style
  314.    case 1: ch = "░"           ; widely spaced block
  315.    case 2: ch = "▒"           ; spaced block
  316.    case 3: ch = "▓"           ; closely spaced block
  317.    case 4: ch = "█"           ; solid block
  318.    case 5: ch = fillchar      ; user-defined fill character
  319.    otherwise:
  320.            ch = " "           ; space
  321. EndSwitch
  322. strset line,ch,1,right-left+1 ; set line to selected fill char
  323. row = top
  324. While row<=bottom
  325.    EchoGotoXY left,row
  326.    Echo line                  ; one line at a time
  327.    row = row+1
  328. EndWhile
  329. EndProc
  330.  
  331.